<%@page language="java" contentType="text/html"%>
<%@page import="org.pomirkovany.beans.Item"%>
<jsp:useBean id="dataAccess" scope="application"
  class="org.pomirkovany.model.DataAccess"/>
<%
  String base = (String)application.getAttribute("base");
  String imageURL = (String)application.getAttribute("imageURL");
  %>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <title>Item details</title>
  <link rel="stylesheet" href="/Cataloguer/css/cataloguer.css" type="text/css"/>
  </head>
<body>
<jsp:include page="header.jsp" flush="true"/>
<jsp:include page="SearchBar.jsp" flush="true"/>
<jsp:include page="typesmenu.jsp" flush="true"/>
<div class="content">
  <h2>Details</h2>
<%
  try {
	  
    String itemId = request.getParameter("itemId");
    Item item = dataAccess.getItemDetails(itemId);
    if (item != null) {
		System.out.println("trouble ");
  %>
      <table>
        <tr>
          <td>
            <img src="<%=(imageURL + item.getPicture())%>" width="62%" height="62%"/> 
            </td>
          <td>
            <b><%=item.getName()%></b><br/>
            <%=item.getAuthor()%><br/>
            Rate: <img border="0" src="images\<%=item.getRate()%>s.png" alt="no picture" width="27%" height="27%" /><br/><br/><br/>
            Date: <%=item.getDate()%><br/>            
            Location: <%=item.getLocation()%><br/>
            Owner:<%=item.getOwner()%><br/>
            Borrowed:<input type="checkbox" name="vehicle"
             <%if(item.isBorrowed()){%>
             checked<%}%> value="" disabled /><br/><br/>
            Comment: <%=item.getComment()%><br/>
            
            
            </td>
          </tr>
        <tr>
          <td colspan="2" align="right">
            <a class="link1"
              href="<%=base%>?action=deleteItem&itemId=<%=item.getId()%>">
              delete</a>
            </td>
          </tr>
           <tr>
          <td colspan="2" align="right">
            <a class="link1"
              href="<%=base%>?action=editItem&itemId=<%=item.getId()%>">
              edit</a>
            </td>
          </tr>
        </table>
<%
      }
    }
  catch (Exception e) {
	%><p class="error">Invalid identifier!</p><%
	
    }
  %>
  </div>
</body>
</html>
